﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Lost_and_Found.Models.DB;
using Lost_and_Found.Models.ObjectManager;

namespace Lost_and_Found.Models.ViewModel
{
    public class TopicInfo
    {
        
        private TopicManager tpManager = new TopicManager();
        public int CountPost;
        public User User;
        public Topic Topic;
        public List<string> Location;
        

        public TopicInfo(Topic topic)
        {
            this.User = topic.User;
            CountPost = tpManager.countTopicPostOfUser(User.Id);
            this.Topic = topic;
            Location = tpManager.getLocationList(Topic.Location);
            
            
        }
        public string getInfoOfItem(Item item){
            List<ValueAttribute> temp = tpManager.getValueAttribute(item.Info);
            string show = "";
            foreach (var s in temp) 
            {
                if (s != temp.Last())
                {
                    show += s.Attribute + ": " + s.Value + " và ";
                }
                else
                {
                    show += s.Attribute + ": " + s.Value + ". ";
                }    
            }
            return show;
        }
    }
}